<?php

namespace backend\models;

use Yii;

/**
 * This is the model class for table "tme_instockdetailsinfo".
 *
 * @property integer $id
 * @property integer $tme_id
 * @property string $merchandiseid
 * @property string $billcode
 * @property integer $num
 * @property double $price
 *
 * @property TmeInstockinfo $id0
 * @property TmeMerchandiseinfo $tme
 */
class TmeInstockdetailsinfo extends \yii\db\ActiveRecord
{
    /**
     * @inheritdoc
     */
    public static function tableName()
    {
        return 'tme_instockdetailsinfo';
    }

    /**
     * @inheritdoc
     */
    public function rules()
    {
        return [
            [['id', 'num', 'price'], 'required'],
            [['id', 'tme_id', 'num'], 'integer'],
            [['price'], 'number'],
            [['merchandiseid', 'billcode'], 'string', 'max' => 20]
        ];
    }

    /**
     * @inheritdoc
     */
    public function attributeLabels()
    {
        return [
            'id' => 'ID',
            'tme_id' => 'Tme ID',
            'merchandiseid' => 'Merchandiseid',
            'billcode' => 'Billcode',
            'num' => 'Num',
            'price' => 'Price',
        ];
    }

    /**
     * @return \yii\db\ActiveQuery
     */
    public function getId0()
    {
        return $this->hasOne(TmeInstockinfo::className(), ['id' => 'id', 'billcode' => 'billcode']);
    }

    /**
     * @return \yii\db\ActiveQuery
     */
    public function getTme()
    {
        return $this->hasOne(TmeMerchandiseinfo::className(), ['ID' => 'tme_id', 'MerchandiseID' => 'merchandiseid']);
    }
}
